/**
 * @ClassName:
 * @Description:
 */
package com.neusoft.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neusoft.base.BaseServiceImpl;
import com.neusoft.config.Pagination;
import com.neusoft.mapper.CommentMapper;
import com.neusoft.model.CommentSearch;
import com.neusoft.po.Comment;
import com.neusoft.service.CommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 评论服务实现
 *
 * @author Lucifer
 * @since 2021/5/15 23:25
 */
@Service
public class CommentServiceImpl extends BaseServiceImpl<Comment> implements CommentService {


    @Resource
    private CommentMapper commentMapper;

    @Override
    public BaseMapper<Comment> getBaseDao() {
        return commentMapper;
    }

    @Override
    public Integer save(Comment entity) {
        Integer id = entity.getId();
        if (null == id) {
            entity.setCreate_time(new Date());
            insert(entity);
            id = entity.getId();
        } else {
            updateById(entity);
        }
        return id;
    }

    @Override
    @Pagination
    public Object page(CommentSearch commentSearch) {
        return commentMapper.list(commentSearch);
    }

    @Override
    public Integer examine(Integer[] ids) {
        return commentMapper.examine(ids);
    }
}
